// struct definition
int red = 0x0000ff, green = 0x00ff00, blue = 0xff0000, gray = 0x888888,darkgray = 0x444444, white = 0xffffff, darkgreen = 0x8800, darkred = 0x88;;

struct GraphNode
{
	int mark;
	V2DF pos;
	char value;
	bool selected;
	int adjVal;
	TemplateVector<GraphEdge> edges;

	GraphNode():value(0),mark(0),selected(false){}

	GraphNode(int value, V2DF position)
		:value(value),pos(position),mark(0),selected(false),adjVal(0)
	{
	}

	void connectTo(GraphNode * next, float cost)
	{
		edges.add(GraphEdge(this, next, cost));
	}

	void draw()
	{
		int var=0;
		bool select = false;
		
		char buffer[10];
		if(!selected)
			drawEdge();
		else
		{
			for(int i = 0; i<edges.size(); ++i)
			{
			glColor3ubv((GLubyte*)&blue);
			sprintf_s(buffer, "%c",(edges.get(i).to->adjVal+'A'));
			edges.get(i).to->pos.glDrawString(buffer);
			}
		}
		for(int i = 0; i<edges.size();++i)
		{
			if(edges.get(i).to->selected)
			{
				select = true;
			}
		}

		if(selected)
		{
			glColor3ubv((GLubyte*)&green);
			sprintf_s(buffer, "%c", value);
			pos.glDrawString(buffer);
		}
		else if(select)
		{
			
		}
		else
		{
			glColor3ubv((GLubyte*)&gray);
			sprintf_s(buffer, "%c", value);
			pos.glDrawString(buffer);
		}
	}
	void markAdj()
	{
		int size;
		size = edges.size();
		for(int i = 0; i<size;++i)
			edges.get(i).to->adjVal=i;
	}
	void drawEdge()
	{
		for(int i = 0; i < edges.size(); ++i)
		{
			if(edges.get(i).to->selected)
			{
				glColor3ubv((GLubyte*)&darkgreen);
				edges.get(i).from->pos.glDrawTo(edges.get(i).to->pos);
			}
			else
			{
				glColor3ubv((GLubyte*)&darkgray);
				edges.get(i).from->pos.glDrawTo(edges.get(i).to->pos);
			}
		}
	}
	void drawNodes()
	{
		char buffer[10];
		for(int i=0;i<edges.size();i++)
		{
			glColor3ubv((GLubyte*)&gray);
			sprintf_s(buffer, "%c", edges.get(i).to->value);
			edges.get(i).to->pos.glDrawString(buffer);
		}
	}
	
};
